package com.huixuebao.after.controller.user;


import com.huixuebao.after.dto.UserDTO;
import com.huixuebao.after.service.UserService;
import com.huixuebao.common.bean.ApiResult;
import com.huixuebao.common.enumeration.ResultCodeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@Slf4j
@RestController
@RequestMapping("/hxb/after/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 新增用户
     * @return
     */
    @PostMapping("/addUser")
    public ApiResult addUser(@RequestBody UserDTO userDTO, HttpServletRequest request){
        return userService.addUser(userDTO,request);
    }

    /**
     * 编辑用户
     * @param userDTO
     * @return
     */
    @PostMapping("/editUser")
    public ApiResult editUser(@RequestBody UserDTO userDTO,HttpServletRequest request){return userService.editUser(userDTO,request);}

    /**
     * 获取用户列表信息
     * @param current
     * @param size
     * @param userName
     * @param userState
     * @return
     */
    @GetMapping("/getUserList")
    public ApiResult getUserList(Integer current, Integer size,String userName,String userCode,Integer userState, HttpServletRequest request) {

        return userService.getUserList(current,size,userName,userCode,userState,request);
    }

    /**
     * 更改用户密码
     * @param userDTO
     * @return
     */
    @PostMapping("/updatePassword")
    public ApiResult updatePassword(@RequestBody UserDTO userDTO){
        return userService.updatePassword(userDTO);
    }
}

